<?php

namespace apiend\modules\user\models;

use Yii;
use yii\data\ActiveDataProvider;

/**
 * 用户评论回复
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class UserCommentSearch extends \common\models\dynamic\DynamicNotice {

    /**
     * @return \yii\data\ActiveDataProvider
     */
    public function search() {
        $query = static::find()->andWhere([
            'author_id' => $this->user_id,
            'reply_id' => 0,
        ]);
        $query->with(['dynamic']);
        $query->orderBy(['created_at' => SORT_DESC]);
        //$query->debug();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        return $dataProvider;
    }

    /**
     * @internal
     */
    public function fields() {
        return [
            'id',
            'dynamic',
            'comment',
            'time' => 'created_at'
        ];
    }

}
